<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dom对话框</title>
</head>
<body>
    <button type="button" onclick="showModal()">确定</button>
    <dialog id="confirm-close-dialog">
        <form method="dialog">
          <p class="discard-message-text">Discard unsaved changes?</p>
          <div class="confirm-close-dialog-btn-container">
            <button id="cancel-btn" class="btn">
              Cancel
            </button>
            <button id="discard-btn" class="btn">
              Discard
            </button>
          </div>
        </form>
      </dialog>
    <script>
     function showModal(){
           const confirmClosedialog = document.getElementById("confirm-close-dialog");
           confirmClosedialog.showModal();
     }
    </script>
</body>
</html>